//NeedAuth.js 用于查看state里的登录状态，如果有登录，就显示此组件的children，如果没有则跳转到LoginPage
import React from 'react'
import { useSelector } from 'react-redux'
import { Navigate} from 'react-router-dom'


const NeedAuth = props => {
    const loginstate = useSelector(state => state.loginpara);
   
    //children小写，很容易搞错
    return loginstate.isLogined ? props.children : <Navigate to="/" /> ;

};

export default NeedAuth
